package main

import (
	"github.com/gin-gonic/gin"
	"github.com/asim/go-micro/v3/web"
)

func main()  {

	//1. micro api
	/*service := web.NewService(web.Address(":8001"))

	service.HandleFunc("/", func(writer http.ResponseWriter, request *http.Request) {
		writer.Write([]byte("hello world"))
	})
	service.Run()*/


	//2. gin api

	//consulReg := consul.NewRegister()

	ginRouter := gin.Default()
	ginRouter.Handle("GET", "/user", func(context *gin.Context) {
		context.String(200, "user api")
	})

	ginRouter.Handle("GET", "/news", func(context *gin.Context) {
		context.String(200, "news api")
	})

	service := web.NewService(
		web.Address(":8001"),
		web.Handler(ginRouter),
		)

	service.Run()

}
